;(function (window, $, undefined) {
    /*
     * tab切换插件
     * 用例：$('*').createTab();
     */
    $.fn.createTab = function (opt) {
        var def = {
            activeEvt: 'mouseover',
            activeCls: 'cur'
        }
        $.extend(def, opt);
        this.each(function () {
            var $this = $(this);
            var timer;
            $this.find('ul.title li').mouseover(def.activeEvt, function () {
                var index = $(this).index(),
                    that = $(this);
                timer = setTimeout(function () {
                    that.addClass('cur').siblings().removeClass('cur');
                    $this.find('div.list').animate({marginLeft: -1000 * index}, 'slow');
                }, 300);
            }).mouseout(function () {
                clearTimeout(timer);
            })
        });
    }

})(window, jQuery);
$(function () {
    $(".jyTable").createTab()
})
$(document).ready(function () {
    var date = new Date();
    $("#calendar").flexoCalendar({setYear: date.getFullYear(), setMonth: date.getMonth(), selectDate: 'each-each-each'});
    /*init_CompanyInfo();
    init_Expire();
    init_Task();*/
});

function openTab(index) {
    switch (index) {
        case"1":
            window.parent.windowtab.addTab("证件管理", "document/documentList.html");
            break;
        case"2":
            window.parent.windowtab.addTab("公司信息", "company/companyInfoList.html");
            break;
        case"3":
            window.parent.windowtab.addTab("人员信息", "staff/personInfoViewList.html");
            break;
        case"4":
            window.parent.windowtab.addTab("房产信息", "voiture/voitureList.html");
            break;
        case"5":
            window.parent.windowtab.addTab("车辆信息", "device/deviceList.html");
            break;
        case"6":
            window.parent.windowtab.addTab("设备信息", "house/houseList.html");
            break;
    }
}
function init_Task() {
    var formData = {
        "page": 0,
        "rows": 10
    };
    var html="";
    ActHttpRequest("bidtaskView!pageList.do",formData, function (data) {
        if (data.rows) {
            var rows = data.rows;
            for (var i = 0; i < rows.length; i++) {
                var info = rows[i];
                var startdate = new Date(info.startTime);
                var finishdate = new Date(info.finishTime);
                startdate= startdate.getFullYear() + '-' + (startdate.getMonth() + 1) + '-' + startdate.getDate();
                finishdate= finishdate.getFullYear() + '-' + (finishdate.getMonth() + 1) + '-' + finishdate.getDate();
                html=html+'<li class="tabtr clearfix"><span style="width: 30%;">'+info.projectName+'</span><span style="width: 40%;">'+info.remark+'</span><span style="width: 30%;">'+finishdate+'</span></li>';
            }
            $("#TaskList").html(html);
        } else {
            mini.alert(data.message);
        }
    }, null, null, null, '加载中。。。', true);
}

function init_Expire() {
    var formData = {
        "documentView.classify":0,
        "page": 0,
        "rows": 8
    };
    var html="";
    ActHttpRequest("documentView!expirePageList.do", formData, function (data) {
        if (data.rows) {
            var rows = data.rows;
            for (var i = 0; i < rows.length; i++) {
                var info = rows[i];
                var date = new Date(info.endDate);
                date= date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                html=html+'<li class="tabtr clearfix"><span style="width: 70%;">'+info.documentName+'</span><span style="width: 30%;">'+date+'</span></li>';
            }
            $("#ExpireList").html(html);
        } else {
            mini.alert(data.message);
        }
    }, null, null, null, '加载中。。。', true);
}

function init_CompanyInfo() {
    var formData = {
        "page": 0,
        "rows": 10
    };
    var html="";
    ActHttpRequest("companyInfoView!pageList.do", formData, function (data) {
        if (data.rows) {
            var rows = data.rows;
            for (var i = 0; i < rows.length; i++) {
                var info = rows[i];
                console.log(info)
                var companyType='内部';
                if(info.companyType==2)companyType='外部';
                html=html+'<li class="tabtr clearfix"><span style="width: 70%;">'+info.companyName+'</span><span style="width: 30%;">'+companyType+'</span></li>';
            }
            $("#companylist").html(html);
        } else {
            mini.alert(data.message);
        }
    }, null, null, null, '加载中。。。', true);
}

